package com.directv.z8training.EMS.Services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.directv.z8training.EMS.DAO.UserDAO;
import com.directv.z8training.EMS.Entity.Project;
import com.directv.z8training.EMS.Entity.ProjectUser;
import com.directv.z8training.EMS.Entity.User;

/**
 * @author HieuLT8
 *
 */
@Service
public class UserManagementImpl implements UserManagement {

	@Autowired
	private UserDAO userDAO;

	@Override
	public User checkLogin(String username, String password) {
		// TODO Auto-generated method stub
		return userDAO.checkLogin(username, password);
	}

	@Override
	@Transactional
	public void createPM(String username, String password, String fullname,
			String address, String phone, String code) {
		// TODO Auto-generated method stub
		userDAO.createPM(username, password, fullname, address, phone, code);

	}

	@Override
	@Transactional
	public void createDEV(String username, String password, String fullname,
			String address, String phone, String projectcode) {
		// TODO Auto-generated method stub
		userDAO.createDEV(username, password, fullname, address, phone,
				projectcode);
	}

	@Override
	public User findUserByUserName(String username) {
		return userDAO.findUserByUserName(username);
	}

	@Override
	@Transactional
	public void removeDEV(String username, String projectCode) {
		// TODO Auto-generated method stub
		userDAO.removeDEV(username, projectCode);
	}

	@Override
	@Transactional
	public void updateInformation(User user,String fullname, String address, String phone) {
		userDAO.updateInformation(user,fullname, address, phone);
	}

	@Override
	public User findUser1(String username) {
		// TODO Auto-generated method stub
		return userDAO.findUser1(username);
	}

	@Override
	public List<ProjectUser> findListProjectUserByUsername(User user) {
		// TODO Auto-generated method stub
		return userDAO.findListProjectUserByUsername(user);
	}

	@Override
	public Project findProjectUserByCode(String code) {
		// TODO Auto-generated method stub
		return userDAO.findProjectUserByCode(code);
	}

	@Override
	public List<User> findAllUser() {
		// TODO Auto-generated method stub
		return userDAO.findAllUser();
	}

	@Override
	@Transactional
	public void changePassword(User user,String password) {
		userDAO.changePassword(user,password);;
	}

	@Override
	public List<User> findListUnprojectUser() {
		// TODO Auto-generated method stub
		return userDAO.findListUnprojectUser();
	}

	@Override
	@Transactional
	public void assignDEVToProject(String username, String projectCode) {
		// TODO Auto-generated method stub
		userDAO.assignDEVToProject(username, projectCode);
	}
	
	@Override
	public boolean checkAvailable(String username) {
		// TODO Auto-generated method stub
		return userDAO.checkAvailable(username);
	}
}
